<template>
  <div class="abnormal-data innerPageTable-out-flex">
    <search-form
      :form-data="formData"
      @search="searchHandle"
      @reset="resetHandle"
      :label-width="120"
    ></search-form>

    <InnerPageTable ref="listTable" :config="pageTableConfig">
      <div slot="table-bar">
        <Button v-show="false">导出</Button>
        <Button @click.native="exportHandle('outlier_data/export')" :disabled="btnDisabled">导出</Button>
      </div>
    </InnerPageTable>
  </div>
</template>

<script>
import SearchForm from "@/components/common/SearchForm";
import { mixin } from "@/views/superviseInfo/mix/mixin";
import {configForm, generateColumns } from './abnormal-constant'
import { superviseInfoAPI } from "@api/superviseInfo";
import detailPage from "@/components/detailInfo";
import { detailField as purchaseDetail } from "@/views/superviseInfo/js/purchase-constant";
import { detailField as performanceDetail } from "@/views/superviseInfo/js/performance-constant";
import { detailField as subjectDetail } from "@/views/superviseInfo/js/subject-constant";
import { detailField as buyerDetail } from "@/views/superviseInfo/js/buyer-constant";
import { detailField as contractDetail } from "@/views/superviseInfo/js/contract-constant";
import { detailField as invoiceDetail } from "@/views/superviseInfo/js/invoice-payment";
import { detailField as sellerDetail } from "@/views/superviseInfo/js/seller-constant";
import { detailField as offerDetail } from "@/views/superviseInfo/js/offer-constant";

import { stateHandleMix } from "@/views/superviseInfo/mix/stateHandleMix";
import { mapState } from "vuex";

export default {
  name: "abnormal-data",
  mixins: [mixin, stateHandleMix],
  components: {
    SearchForm
  },
  computed: {
    searchData() {
      return configForm.bind(this)()
    }
  },
  data() {
    return {
      // formData: configForm.bind(this)(),
      pageTableConfig: {
        loadDataFn: this.getTableList,
        columns: generateColumns.bind(this)(),
        autoFirst: true,
        // border: true,
        initParam: {
          "crsrmBiddingId": "",
          "crsrmBiddingName": "",
          "crsrmContractCode": "",
          "crsrmContractName": "",
          "crsrmFrameworkAgreementId": "",
          "crsrmPurchaserCode": "",
          "crsrmPurchaserName": "",
          "crsrmSupplierName": "",
          "crsrmSupplierSocialCredit": "",
          "dataProblemsInfo": "",
          "resultState": [],
          "startDate": 0,
          "endDate": 0,
          "crsrmState": ''
        },
        onSelectionChange: this.selectHandle,
      },
      tableObj: {
        purchaserTable: [purchaseDetail, 'purchaseDetail', 'purchase-info'],
        purchaserAgreeTable: [performanceDetail, 'performanceDetail', 'performance-info'],
        purchaserBidTable: [subjectDetail, 'subjectDetail', 'subject-info'],
        purchaserBuyerTable: [buyerDetail, 'buyerDetail', 'buyer-info'],
        purchaserConTractTable: [contractDetail, 'contractDetail', 'contract-info'],
        purchaserInvoiceTable: [invoiceDetail, 'invoiceDetail', 'invoice-payment'],
        purchaserSellerTable: [sellerDetail, 'sellerDetail', 'seller-info'],
        purchaserSupplierTable: [offerDetail, 'offerDetail', 'offer-supplier']
      }
    }
  },
  methods: {
    getTableList(tableObj) {
      let { responseProcess, initParam, param } = tableObj;
      const params = {
        ...param,
        ...initParam
      };
      superviseInfoAPI.getAbnormalData(params).then(res => {
        responseProcess(res.data);
      })
    },
    detailHandle(row) {
      let detailInfo = {}
      if (!row.dataProblemsInfo) return
      const detailApi = this.tableObj[row.dataProblemsInfo][1]
      this.$Spin.show()
      superviseInfoAPI[detailApi]({ id: row.id }).then(res => {
        detailInfo = res.data
        this.$Spin.hide()
        console.log('ssss', row);
        new this.$sidelipPage(detailPage, { props: { detailInfo, detailField: this.tableObj[row.dataProblemsInfo][0], tableBelong: this.tableObj[row.dataProblemsInfo][2], title: '发票付款详情' }, isNav: false});
      })
    },
  }
};
</script>

<style scoped>

</style>
